//
//  CustomRow.swift
//  MyCloset
//
//  Created by 牟好好 on 2024/11/21.
//

import SwiftUI

struct CustomRecommendsRow: View {
    var item1: String
    var item2: String
    var isColor: Bool
    @Binding var isShowTrash: Bool
    var action: () -> Void
    
    var body: some View {
        HStack {
            if isColor {
                ColorItem(color: item1)
                ColorItem(color: item2)
            } else {
                Text(item1)
                Text(item2)
            }
            if isShowTrash {
                Spacer()
                Button(action: {
                    action()
                }, label: {
                    Image(systemName: "trash")
                        .foregroundStyle(.red)
                        .font(.system(size: 18, weight: .bold))
                })
            }
        }
        .foregroundStyle(.accent)
        .font(.system(size: 20, weight: .bold))
        .padding(.all, 10)
        .frame(maxWidth: boundsWidth * 0.6)
        .background(Color("cardColor"))
        .clipShape(RoundedRectangle(cornerRadius: 8))
//        .overlay {
//            RoundedRectangle(cornerRadius: 8)
//                .stroke(lineWidth: 2)
//                .foregroundStyle(.gray.opacity(0.3))
//                .shadow(color: .accent, radius: 12, x: 4, y: 4)
//        }
    }
}

struct CustomStyleView: View {
    var item: String
    var isChoosed: Bool
    var action: () -> Void
    
    var body: some View {
        Button(action: {
            action()
        }, label: {
            Text(item)
                .foregroundStyle(.white)
                .font(.system(size: 18, weight: .bold))
        })
        .padding(.all, 10)
        .background(isChoosed ? .blue : Color("cardColor"))
        .clipShape(Capsule())
        .animation(.spring(duration: 0.1), value: isChoosed)
    }
}

#Preview {
    CustomRecommendsRow(item1: "黄色", item2: "红色", isColor: true, isShowTrash: .constant(true)) {}
}

#Preview {
    CustomRecommendsRow(item1: "格纹", item2: "直筒裤", isColor: false, isShowTrash: .constant(true)) {}
        .preferredColorScheme(.dark)
}

#Preview {
    CustomStyleView(item: "格纹", isChoosed: true) {}
}

#Preview {
    CustomStyleView(item: "格纹", isChoosed: true) {}
        .preferredColorScheme(.dark)
}
